# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>

pkgname=python-xmlschema
_pkgname="${pkgname#python-}"
pkgver=2.2.3
pkgrel=1
pkgdesc='An XML Schema validator and decoder'
arch=('any')
url='https://github.com/sissaschool/xmlschema'
license=('MIT')
depends=('python' 'python-elementpath')
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-wheel'
  'python-setuptools'
)
checkdepends=('python-lxml' 'python-jinja')
optdepends=('python-jinja: for XSD based code generators')
_commit='bc42319c95abc380b1c6a254e94f2c3f5628fd16'
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

  python -m build --wheel --no-isolation
}

check() {
  cd "$pkgname"

  PYTHONPATH="$PWD" python -m unittest
}

package() {
  cd "$pkgname"

  python -m installer --destdir="$pkgdir" dist/*.whl

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
